﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x02000310 RID: 784
public class NPCSpawner : MonoBehaviour
{
	// Token: 0x060013DF RID: 5087 RVA: 0x00084678 File Offset: 0x00082878
	private void Start()
	{
		NPCSpawner.Instance = this;
		this.cam = base.GetComponent<PlayerCamera>();
		this.agentController = base.GetComponent<ObjectManager>();
		this.NPCListMale = this.agentController.maleMicroModels;
		this.NPCListFemale = this.agentController.femaleMicroModels;
	}

	// Token: 0x060013E0 RID: 5088 RVA: 0x000846C8 File Offset: 0x000828C8
	public void SpawnMicro(bool female)
	{
		Vector3 vector = this.cam.target.transform.position + (this.cam.target.transform.forward + Vector3.up) * this.cam.targetScale * 2f;
		ClientPlayer.Instance.CallCmdSpawnMicro(female, vector.ToVirtual(), Quaternion.identity, this.cam.targetScale);
	}

	// Token: 0x060013E1 RID: 5089 RVA: 0x0008474C File Offset: 0x0008294C
	public MicroNPC SpawnMaleNPC()
	{
		if (this.NPCListMale.Count > 0)
		{
			int index = UnityEngine.Random.Range(0, this.NPCListMale.Count);
			return this.NPCListMale[index];
		}
		Debug.LogError("No Male micro found");
		return null;
	}

	// Token: 0x060013E2 RID: 5090 RVA: 0x00084794 File Offset: 0x00082994
	public MicroNPC SpawnFemaleNPC()
	{
		if (this.NPCListFemale.Count > 0)
		{
			int index = UnityEngine.Random.Range(0, this.NPCListFemale.Count);
			return this.NPCListFemale[index];
		}
		Debug.LogError("No female micro found");
		return null;
	}

	// Token: 0x060013E3 RID: 5091 RVA: 0x000847DC File Offset: 0x000829DC
	public MicroNPC SpawnMaleNPC(string name)
	{
		MicroNPC microNPC = this.NPCListMale.Find((MicroNPC mNpc) => mNpc.name == name);
		if (microNPC == null)
		{
			Debug.LogError("No Male micro found by the name \"" + name + "\"");
			return this.SpawnMaleNPC();
		}
		return microNPC;
	}

	// Token: 0x060013E4 RID: 5092 RVA: 0x0008483C File Offset: 0x00082A3C
	public MicroNPC SpawnFemaleNPC(string name)
	{
		MicroNPC microNPC = this.NPCListFemale.Find((MicroNPC mNpc) => mNpc.name == name);
		if (microNPC == null)
		{
			Debug.LogError("No Female micro found by the name \"" + name + "\"");
			return this.SpawnFemaleNPC();
		}
		return microNPC;
	}

	// Token: 0x04001722 RID: 5922
	public static NPCSpawner Instance;

	// Token: 0x04001723 RID: 5923
	private List<MicroNPC> NPCListMale;

	// Token: 0x04001724 RID: 5924
	private List<MicroNPC> NPCListFemale;

	// Token: 0x04001725 RID: 5925
	public GameObject blood;

	// Token: 0x04001726 RID: 5926
	private PlayerCamera cam;

	// Token: 0x04001727 RID: 5927
	private ObjectManager agentController;
}
